package com.niit.onlinemusicserver.controller;

import com.niit.onlinemusicserver.common.R;
import com.niit.onlinemusicserver.model.request.CommentRequest;
import com.niit.onlinemusicserver.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CommentController {
  @Autowired
  private CommentService commentService;

  // 提交评论
  @PostMapping("/comment/add")
  public R addComment(@RequestBody CommentRequest addCommentRequest) {
    return commentService.addComment(addCommentRequest);
  }

  // 删除评论
  @GetMapping("/comment/delete")
  public R deleteComment(@RequestParam Integer id) {
    return commentService.deleteComment(id);
  }

  // 获得指定歌曲 ID 的评论列表
  @GetMapping("/comment/song/detail")
  public R commentOfSongId(@RequestParam Integer songId) {
    return commentService.commentOfSongId(songId);
  }

  // 获得指定歌单 ID 的评论列表
  @GetMapping("/comment/songList/detail")
  public R commentOfSongListId(@RequestParam Integer songListId) {
    return commentService.commentOfSongListId(songListId);
  }

  // 点赞
  @PostMapping("/comment/like")
  public R commentOfLike(@RequestBody CommentRequest upCommentRequest) {
    return commentService.updateCommentMsg(upCommentRequest);
  }

}